package org.idea.test;

import com.google.gson.Gson;
import org.idea.entity.Bank;

/**
 * Gson 工具类的简单使用
 *
 * @Author zqx
 * @Date 2023-10-25
 */
public class MainTestGson01 {
    public static void main(String[] args) {
        Bank bank = new Bank() ;

        bank.setCustomerId(10086);
        bank.setCustomerName("中国移动");
        bank.setCurrentMoney(100);

        // 把 bank 对象序列化为一个 JSON 字符串 - {customerId:10086,customerName:'中国移动',currentMoney:100}
        Gson gson = new Gson();

        String json = gson.toJson(bank);
        System.out.println(json);


    }
}
